/* eslint-disable no-console */
const express = require('express');
const app = express();
const services = require('./services/index.js');
const port = 3001;

services.forEach(({ url, method, data }) => {
  app[method](url, (req, res) => {
    res.send(typeof data === 'function' ? data() : data);
  });
});

app.listen(port, () => {
  console.log(`mock服务器启动，地址为：http://localhost:${port}`);
});
